<template>
  <div class="input02">
    <label v-if="title!==''">{{title}}:</label>
    <el-input
      onkeyup="this.value=this.value.replace(/\D/g,'')" 
      onmousedown="this.value=this.value.replace(/\D/g,'')"
      v-on:input="inputF"
      class="input02-input"
      :placeholder="placeholder"
      v-model="val"
    >
    <i slot="suffix" v-bind:class="[icon, 'el-input__icon']"></i>
    </el-input>
  </div>
</template>
<style scoped>
.input02 {
  margin: 5px 0px;
}
label{
    display: inline-block;
    min-width: 35px;
}
.input02-input {
  width: auto !important;
}
.input02 i {
  font-size: 18px;
}
.input02 >>> .el-input__inner {
  background: #ffffff;
  /* text-align: center; */
  /* text-align: center; */
  width: 100%!important;
  height: 32px;
}
</style>
<script>
export default {
  name: "input06",
  props: {
    title: {
      default: ""
    },
    icon: {
      default: ""
    },
    value: {
      default: ""
    },
    placeholder:{
      default:'请输入正整数'
    }
  },
  meta: {
    descr: "只能输入正整数输入框"
  },
  data() {
    return {
      val: ""
    };
  },
  methods:{
    inputF(){
      let that = this;
      this.val=this.val.replace(/\D/g,'')
    }
  },
  created() {
    this.val = this.value;
  },
  watch: {
    val(value) {
      this.$emit("input", value);
    },
    value(){
        this.val = this.value;
    }
  }
};
</script>
